<template>
  <div style="width: 100%;height: 100%;padding: 5px;">
    <Echart
      :options="options"
      :id="id"
      height="100%"
      width="100%"
    ></Echart>
  </div>
</template>

<script>
import Echart from '@/common/echart'
export default {
  data() {
    return {
      options: {},
    }
  },
  components: {
    Echart
  },
  props: {
    cdata: {
      type: Object,
      default: () => ({})
    },
    id: {
      type: String
    }
  },
  watch: {
    cdata: {
      handler(newData) {
        this.options = {
          tooltip: {
            trigger: 'axis'
          },
          legend: {
            data: newData.legendList,
            top: "4%"
          },
          grid: {
            left: "12%",
            bottom: "15%",
            top: "15%",
            width: "80%"
          },
          xAxis: {
            type: 'category',
            boundaryGap: false,
            data: newData.xAxisList
          },
          yAxis: {
            type: 'value',
            splitNumber: 3,
            splitLine: { show: false },
            axisLine: {
              lineStyle: {
                color: "#B4B4B4"
              }
            }
          },
          series: newData.seriesList
        };
      },
      immediate: true,
      deep: true
    }
  }
}
</script>
